home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / intuition / pointinimage.c < prev    next >
C/C++ Source or Header  |  1996-10-24  |  2KB  |  103 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: pointinimage.c,v 1.2 1996/10/24 15:51:23 aros Exp $
  4.     $Log: pointinimage.c,v $
  5.     Revision 1.2  1996/10/24 15:51:23  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.1  1996/10/23 15:33:52  aros
  9.     Three new functions: DrawImageState(), EraseImage() and PointInImage()
  10.     by C. Aldi.
  11.  
  12.     First version of IMAGECLASS by C. Aldi
  13.  
  14.  
  15.     Desc:
  16.     Lang: english
  17. */
  18. #include "intuition_intern.h"
  19. #include <intuition/classusr.h>
  20. #include <clib/alib_protos.h>
  21.  
  22. /*****************************************************************************
  23.  
  24.     NAME */
  25.     #include <intuition/intuition.h>
  26.     #include <intuition/imageclass.h>
  27.     #include <clib/intuition_protos.h>
  28.  
  29.     AROS_LH2(BOOL, PointInImage,
  30.  
  31. /*  SYNOPSIS */
  32.     AROS_LHA(ULONG,          point, D0),
  33.     AROS_LHA(struct Image *, image, A0),
  34.  
  35. /*  LOCATION */
  36.     struct IntuitionBase *, IntuitionBase, 104, Intuition)
  37.  
  38. /*  FUNCTION
  39.     Check whether a point is inside an image.
  40.  
  41.     INPUTS
  42.     point - This are the packed point coordinates. The X coordinate
  43.         in in the upper 16 bits and the Y coordinate is in the
  44.         lower 16 bits. The coordinates are signed.
  45.     image - Check against this image.
  46.  
  47.     RESULT
  48.     TRUE is the point is inside the image, FALSE otherwise.
  49.  
  50.     NOTES
  51.  
  52.     EXAMPLE
  53.  
  54.     BUGS
  55.  
  56.     SEE ALSO
  57.  
  58.     INTERNALS
  59.  
  60.     HISTORY
  61.     29-10-95    digulla automatically created from
  62.                 intuition_lib.fd and clib/intuition_protos.h
  63.  
  64. *****************************************************************************/
  65. {
  66.     AROS_LIBFUNC_INIT
  67.     AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  68.     BOOL result;
  69.     WORD X = (point >> 16L);
  70.     WORD Y =  point & 0x0000FFFFL;
  71.  
  72.     if (image != NULL)
  73.     {
  74.     if (image->Depth == CUSTOMIMAGEDEPTH)
  75.     {
  76.         /* I'm making a possibly wrong assumption here regarding the
  77.          * X/Y point structure and the packed word order of the point.
  78.          */
  79.         result = (BOOL)DoMethod((Object *)image,
  80.         IM_HITTEST, (WORD)X, (WORD)Y
  81.         );
  82.     }
  83.     else
  84.     {
  85.  
  86.         if ((X >= image->LeftEdge && X <= image->LeftEdge + image->Width) &&
  87.         (Y >= image->TopEdge  && Y <= image->TopEdge  + image->Height)
  88.         )
  89.         {
  90.         result = TRUE;
  91.         }
  92.     }
  93.     }
  94.     else
  95.     {
  96.     /* NULL image returns TRUE per intuition autodoc! */
  97.     result = TRUE;
  98.     }
  99.  
  100.     return (result);
  101.     AROS_LIBFUNC_EXIT
  102. } /* PointInImage */
  103.